<?php

use Phinx\Db\Adapter\MysqlAdapter;
use think\migration\Migrator;
use think\migration\db\Column;

class UserTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('user');
        $table->addColumn('nickname','string',array('limit' => 30,'default' => '','comment' => '用户昵称'));
        $table->addColumn('avatar','string',array('limit' => 255,'default' => '','comment' => '用户头像'));
        $table->addColumn('gender','boolean',array('limit' => 1, 'comment' => ' 0 未知 1 男 2 女','default' => 0));
        $table->addColumn('phone','char',array('limit' => 15,'default' => '0','comment' => '用户手机号'));
        $table->addColumn('username','string',array('limit' => 30, 'default' => '', 'comment' => '用户账号'))->addIndex('username',['unique' => true]);
        $table->addColumn('password','string',array('limit' => 255,'comment' => '用户密码'));
        $table->addColumn('status','boolean',array('limit' => 1, 'comment' => '是否拉黑 0 否 1是','default' => 0));
        $table->addTimestamps('create_time','update_time');
        $table->create();
    }
}
